<template>
    <div>
        <jsscom-heard />
        <div class="cons">
            <div class="pu-con pc-0">
                <p>当前位置：中国广告协会 > 商家推荐</p>
            </div>
            <div class="pc-1 pu-con">
                <div class="pc-left">
                    <div class="huiwai">
                        <div class="hu-2" v-if="newsList.length>0">
                            <router-link
                                :to="{path:'/gxzd/huwai/dec',query:{data:JSON.stringify(item) }}"
                                v-for="(item,index) in newsList "
                                :key="index"
                            >
                                <p>
                                    <strong>{{item.area.match(/-(\S*)-(\S*)/)[1]}}</strong>
                                    ·
                                    <strong>{{item.title}}</strong>
                                </p>
                                <div>
                                    <img :src="prefixUrl+item.img1.split(',')[0]" alt />
                                    <div>
                                        <p>
                                            <strong>公司名称：</strong>
                                            <strong>{{item.company}}</strong>
                                        </p>
                                        <span>
                                            <p>
                                                <strong>媒体类型：</strong>
                                                <strong>{{item.mediaName}}</strong>
                                            </p>
                                            <p>
                                                <strong>广告预算：¥</strong>
                                                <strong>{{item.budget}}</strong>
                                                <strong>万元/月</strong>
                                            </p>
                                        </span>
                                        <p>
                                            <strong>详细地址：</strong>
                                            <strong>{{item.address}}</strong>
                                        </p>
                                        <p>
                                            <strong>广告咨询热线：</strong>
                                            <strong v-if="userType==1">{{item.phone}}</strong>
                                            <strong v-else style="font-size:14px">VIP等级过低，无查看权限</strong>
                                        </p>
                                    </div>
                                </div>
                            </router-link>
                        </div>
                        <div class="hu-2" v-else>
                            <p>暂无数据</p>
                        </div>
                        <div class="news-page">
                            <el-pagination
                                background
                                layout="prev, pager, next"
                                :total="totalSum"
                                :page-size="sizeSum"
                                @size-change="handleSizeChange"
                                @current-change="handleCurrentChange"
                            ></el-pagination>
                        </div>
                    </div>
                </div>
                <div class="pc-right">
                    <h1>产业园推荐</h1>
                    <div class="pcr-con" v-if="ggtjList.length>0">
                        <router-link
                            :to="{path:'/gxzd/gglist/dec',query:{data:JSON.stringify(item) }}"
                            v-for="(item,index) in ggtjList.slice(0,3)"
                            :key="index"
                        >
                            <img :src="prefixUrl+item.imgUrl1" alt />
                            <h2>{{item.title}}</h2>
                        </router-link>
                    </div>
                    <div class="pcr-con" v-else>
                        <p>暂无数据</p>
                    </div>
                </div>
            </div>
            <div style="height:25px"></div>
            <div class="pu-con pc-5">
                <router-link to>
                    <img src="../../../assets/g-10.png" alt />
                </router-link>
            </div>
        </div>
        <com-foot></com-foot>
    </div>
</template>

<script>
import jsscomHeard from '@/components/gxzd-heard'
import comFoot from '@/components/com-foot'

export default {
    components: {
        jsscomHeard,
        comFoot
    },
    filters: {
        pattime(value) {
            return value.slice(0, 10)
        }
    },
    data() {
        return {
            prefixUrl: '',
            totalSum: 0,
            sizeSum: 10,
            input: '',
            ggtjList: [],
            newsList: [],
            mediaName: '',
            userType: 0
        }
    },
    created() {
        this.prefixUrl = this.$store.state.user.imgUrl
        this.userType = this.$store.getters.user.userType
        this.mediaName = this.$route.query.mediaName
        this.getToIndexListCy()
        this.getPageSupplyDemand(1)

    },
    mounted() {

    },
    methods: {
        async getPageSupplyDemand(curIndex) {
            const data = { type: 1, currentPage: curIndex, pageSize: 10, mediaName: this.mediaName }
            const res = await this.$store.dispatch('access/getPageSupplyDemand', data)
            this.newsList = res.list
            this.totalSum = res.totalCount
            console.log(res)
        },
        async getToIndexListCy() {
            const res = await this.$store.dispatch('access/getToIndexListCy')
            this.ggtjList = res
            console.log(res)
        },
        uncultivated() {
            this.$message({
                message: '功能暂未开放，敬请期待',
                type: 'warning'
            });
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(val)
            this.getPageSupplyDemand(val)
        },
    }
}
</script>

<style scoped>
@import "./huwai.css";
</style>
